//
//  YDExpectedReferenceCell.m
//  PeiZiWangBei
//
//  Created by LK-IOS on 2018/3/5.
//  Copyright © 2018年 LK-IOS. All rights reserved.
//

#import "YDExpectedReferenceCell.h"
#import "YDExpectedReferenceModel.h"



@interface YDExpectedReferenceCell()
//label的宽高
@property (nonatomic , assign) CGFloat labelW;
@property (nonatomic , assign) CGFloat labelH;



@end

@implementation YDExpectedReferenceCell

-(void)setModel:(YDExpectedReferenceModel *)model
{
    _model = model;
    
    self.labelL.text = model.hopeRate;
    
    self.labelM.text = model.profitRate;
    
    self.labelR.text = model.profitMoney;
}

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *expectedReferenceCell = @"YDExpectedReferenceCell";
    YDExpectedReferenceCell *cell = [tableView dequeueReusableCellWithIdentifier:expectedReferenceCell];
    if (cell == nil) {
        cell = [[YDExpectedReferenceCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:expectedReferenceCell];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        self.backgroundColor = [UIColor whiteColor];
        
        [self initConfig];//
        
        [self labelL];
        [self labelM];
        [self labelR];
    }
    return self;
}

-(void)initConfig
{
    _labelW = (LKScreenW - rate375(20) * 2) / 3;
    _labelH = (isPhoneX ? rateX812(135) : rate750(135)) * 0.2;
}

-(UILabel *)labelL
{
    if (_labelL == nil) {
        UILabel *labelL = [[UILabel alloc] init];
        [self.contentView addSubview:labelL];
        labelL.textColor = [UIColor colorWithHexString:dark];
        labelL.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        labelL.textAlignment = NSTextAlignmentCenter;
        labelL.text = @"预期涨幅";
        labelL.adjustsFontSizeToFitWidth = YES;
        [labelL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.bottom.equalTo(self);
            make.width.equalTo(@(self.labelW));
        }];
        _labelL = labelL;
    }
    return _labelL;
}

-(UILabel *)labelM
{
    if (_labelM == nil) {
        UILabel *labelM = [[UILabel alloc] init];
        [self.contentView addSubview:labelM];
        labelM.textColor = [UIColor colorWithHexString:dark];
        labelM.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        labelM.textAlignment = NSTextAlignmentCenter;
        labelM.text = @"预期涨幅";
        labelM.adjustsFontSizeToFitWidth = YES;
        [labelM mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.equalTo(self);
            make.width.equalTo(@(self.labelW));
            make.left.equalTo(self.labelL.mas_right);
        }];
        _labelM = labelM;
    }
    return _labelM;
}

-(UILabel *)labelR
{
    if (_labelR == nil) {
        UILabel *labelR = [[UILabel alloc] init];
        [self.contentView addSubview:labelR];
        labelR.textColor = [UIColor colorWithHexString:dark];
        labelR.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        labelR.textAlignment = NSTextAlignmentCenter;
        labelR.text = @"预期涨幅";
        labelR.adjustsFontSizeToFitWidth = YES;
        [labelR mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.top.bottom.equalTo(self);
            make.width.equalTo(@(self.labelW));
        }];
        _labelR = labelR;
    }
    return _labelR;
}

@end
